<?php
include_once "filtro_cabecera.php";
include_once "../funciones/funciones_php.php";
?>
<html>
<head>
<link type="text/css" href="../css/start/jquery-ui-1.8.14.custom.css" rel="Stylesheet" />
<link rel="stylesheet" href="../css/plantilla.css" type="text/css" media="screen">
<link rel="stylesheet" type="text/css" href="../css/tabla.css" />
        <script type="text/javascript" src="../js/jquery-1.5.2.js"></script>
		<script type="text/javascript" src="../js/jquery-ui-1.8.14.custom.min.js"></script>
        <script type='text/javascript' src='../js/jquery.autocomplete.js'></script>
        <script type="text/javascript" src="../js/jquery.validate.js"></script>
        <script type='text/javascript' src='../js/funciones_js.js'></script>
		<link type="text/css" href="../css/start/jquery-ui-1.8.14.custom.css" rel="Stylesheet" />
		<!--<link type="text/css" href="../css/demos.css" rel="Stylesheet" />-->
		<!--<link rel="stylesheet" type="text/css" href="../css/thickbox.css" />-->
        <link rel="stylesheet" type="text/css" href="../css/plantilla.css" />
		<link rel="stylesheet" type="text/css" href="../css/jquery.autocomplete.css" />
		<link rel="stylesheet" type="text/css" href="../css/menu.css" />

    <script>
        $(document).ready(function()
        {
            $('#cerrar').button();
        });
    </script>

</head>
<body>
<div id="titulo_seccion">
<fieldset>
    <table>
        <tr>
            <td><font>Detalle Ordenes de Flete</font></td>
        </tr>
    </table>
</fieldset>
</div>
<br />
<fieldset>

<?php
$depto = $_GET['nro_depto'];
$cliente = $_GET['cliente'];

conectar();
$pg = sprintf("SELECT *
               FROM orden_flete,comuna
               WHERE orden_flete.id_cliente_departamento = '%d'
               AND orden_flete.id_cliente = '%s'
               AND orden_flete.id_comuna = comuna.id_comuna
               AND subtotal > 0",pg_escape_string($depto),pg_escape_string($cliente));
$conectar = pg_query($pg) or die ("Error en la consulta");

echo "<table border=0 cellspacing=0 class=data>
      <thead class=data>";
echo "<tr>
        <th>Orden de Flete</th>
        <th>Destino</th>
        <th>Fecha emision</th>
        <th>Subtotal</th>
      </tr>
      <thead>";

$i = 0;

while($reg = pg_fetch_array($conectar))
{
    $id_orden = $reg['id_orden_flete'];
    $subtotal = $reg['subtotal'];
    $fecha_emision = $reg['fecha_emision'];
    $comuna = $reg['comuna'];

    ($i % 2 == 0 )? $clase = " " : $clase = "class=odd";

    echo "<tbody class=data>
          <tr " . $clase . ">
            <td>" . $id_orden . "</td>
            <td>" . $comuna . "</td>
            <td>" . $fecha_emision . "</td>
            <td>" . $subtotal . "</td>
          </tr>
          </tbody>";
    $i++;
}
echo "</table>";

?>
<br />
<center><input type=button value="Cerrar" name="cerrar" id="cerrar" onclick="cerrar_ventana()"></center>
</fieldset>
</body>
</html>